fix(config): add fnmatch glob support for ConditionalParameter filter#689
Open
jaytoone wants to merge 1 commit into
Open
fix(config): add fnmatch glob support for ConditionalParameter filter#689jaytoone wants to merge 1 commit into
jaytoone wants to merge 1 commit into
Conversation
The filter field in ConditionalParameter previously used plain substring matching. This causes issues on FLA/hybrid-attention models where 'attn' matches both self_attn and linear_attn tensors (A_log, dt_bias, etc.) which are SSM state tensors that must not be donor-blended. Add fnmatch glob support: when filter contains * ? [ metacharacters, use fnmatch.fnmatch instead of substring match. Backward compatible. Users should write filter: '*self_attn*' instead of filter: 'attn' on FLA-hybrid models to avoid the cross-match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ConditionalParameter.filteruses a plain substring check, which causes silent mismatches in hybrid-attention models (e.g. FLA / linear-attention architectures).A filter of
"attn"substring-matches bothself_attnandlinear_attnweights, causing unintended blending of SSM state tensors (A_log,dt_bias, etc.) that must remain intact during merging.Solution
Add glob metacharacter detection (
*,?,[) in_filter_matches(). When the filter string contains any of these characters, usefnmatch.fnmatchinstead of the substring check. Plain strings retain the original substring behaviour for backward compatibility.Changes
mergekit/config.py: addfnmatchimport,_GLOB_CHARSfrozenset, and_filter_matches()helper; updateevaluate_setting()to use ittests/test_config_filter.py: 13 new tests covering plain substring (backward compat), glob patterns, and the linear_attn collision caseTests
Motivation
Discovered while merging FLA-based models (e.g. Jackrong-27B) with standard-attention bases using DARE-TIES. The substring collision corrupted linear-attention SSM parameters, silently degrading model quality. This fix allows users to opt into precise control by writing
"*self_attn*"while preserving existing configs that use plain substrings.Note
Medium Risk
Changes which tensors match conditional merge parameters; glob patterns alter behavior vs old substring-only configs, though plain filters are unchanged.
Overview
ConditionalParameter
filtermatching in merge YAML now supports optional glob patterns (*,?,[) via a new_filter_matches()helper, while plain strings still use substring matching for backward compatibility.When a filter contains glob metacharacters,
evaluate_setting()usesfnmatch(with*{pattern}*wrapping) so patterns like*self_attn*can target standard attention weights without also matchinglinear_attntensors—avoiding unintended blending of SSM state (e.g.A_log,dt_bias) on hybrid / linear-attention models.Adds
tests/test_config_filter.pywith unit and integration coverage for substring compat, glob behavior, and theattnvslinear_attncollision case.Reviewed by Cursor Bugbot for commit 2ada4e6. Bugbot is set up for automated code reviews on this repo. Configure here.